R/02 - Injury Date Cleanup.R

Defines functions injury_dt_cleanup

Documented in injury_dt_cleanup

#' Calculating Injury Date when Injury Date is missing using AGE PLUS Date of Birth
#'
#' @param age Raw AGE of Patient
#' @param dob Date of Birth
#' @param injury_dt Date of Injury
#'
#' @return Returns a calculated Injury Date based on the Date of Birth and Age of Patient
#' @export
injury_dt_cleanup <- function(age, dob, injury_dt) {

  col_value <- ifelse(is.na(injury_dt), as.character(mdy(dob)+years(age)), injury_dt)

  return(col_value)
}
mjkarlsen/traumaR documentation built on June 10, 2020, 2:45 p.m.